package com.ufcg.lvc.client.prototipacao;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DateLabel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.ufcg.lvc.client.GreetingService;
import com.ufcg.lvc.client.GreetingServiceAsync;

public class Cadastro {

	AbsolutePanel rootPanel;
	List<String> listaTitulos;

	public static GreetingServiceAsync getServico() {
		return GWT.create(GreetingService.class);
	}

	public Cadastro() {

		final AsyncCallback<List<String>> callback = new AsyncCallback<List<String>>() {

			@Override
			public void onSuccess(List<String> result) {
				listaTitulos = result;
			}

			@Override
			public void onFailure(Throwable caught) {
				Window.alert("Erro ao carregar questoes");
				System.out.println("Erro ao carregar questoes");
			}
		};
		getServico().getLista("questao", "titulo", callback);
		System.out.println("Tela inicial");
		// Add the nameField and sendButton to the RootPanel
		// Use RootPanel.get() to get the entire body element
		rootPanel = new AbsolutePanel();
		rootPanel.setStyleName("dialogVPanel");
		rootPanel.setSize("1160px", "790px");

		rootPanel.getElement().getStyle().setPosition(Position.RELATIVE);
		AbsolutePanel menuPanel = new AbsolutePanel();
		menuPanel.setStyleName("gwt-panelColorido");
		rootPanel.add(menuPanel, 0, 0);
		menuPanel.setSize("232px", "877px");

		final AbsolutePanel panelRegistro = new AbsolutePanel();
		rootPanel.add(panelRegistro, 238, 64);
		panelRegistro.setSize("905px", "712px");
		
		Label lblNovoCadastro = new Label("Cadastrar");
		lblNovoCadastro.setStyleName("gwt-TituloMedio");
		panelRegistro.add(lblNovoCadastro, 0, 0);
		
		Label lblNewLabel = new Label("Nome completo:");
		panelRegistro.add(lblNewLabel, 60, 69);
		
		Label lblEmail = new Label("E-mail:");
		panelRegistro.add(lblEmail, 60, 111);
		
		Label lblUsurio = new Label("Usuário:");
		panelRegistro.add(lblUsurio, 60, 151);
		
		Label lblSenha = new Label("Senha:");
		panelRegistro.add(lblSenha, 60, 195);
		
		Label lblConfirmarSenha = new Label("Confirmar senha:");
		panelRegistro.add(lblConfirmarSenha, 60, 239);
		
		Label lblNmeroDoCato = new Label("Número do catão:");
		panelRegistro.add(lblNmeroDoCato, 60, 328);
		
		Label lblNomeImpressoNo = new Label("Nome impresso no cartão:");
		panelRegistro.add(lblNomeImpressoNo, 60, 371);
		
		Label lblBandeira = new Label("Bandeira:");
		panelRegistro.add(lblBandeira, 60, 461);
		
		Label lblCdigoDeSegurana = new Label("Código de segurança:");
		panelRegistro.add(lblCdigoDeSegurana, 60, 414);
		
		Label lblVencimento = new Label("Vencimento");
		panelRegistro.add(lblVencimento, 60, 507);
		
		TextBox textBox = new TextBox();
		panelRegistro.add(textBox, 264, 69);
		textBox.setSize("358px", "17px");
		
		TextBox textBox_1 = new TextBox();
		panelRegistro.add(textBox_1, 264, 111);
		textBox_1.setSize("358px", "17px");
		
		TextBox textBox_2 = new TextBox();
		panelRegistro.add(textBox_2, 264, 151);
		textBox_2.setSize("213px", "17px");
		
		TextBox textBox_3 = new TextBox();
		panelRegistro.add(textBox_3, 264, 195);
		textBox_3.setSize("213px", "17px");
		
		TextBox textBox_4 = new TextBox();
		panelRegistro.add(textBox_4, 264, 239);
		textBox_4.setSize("213px", "17px");
		
		TextBox textBox_5 = new TextBox();
		panelRegistro.add(textBox_5, 264, 328);
		textBox_5.setSize("213px", "17px");
		
		ListBox listBox = new ListBox();
		panelRegistro.add(listBox, 264, 461);
		listBox.setSize("223px", "27px");
		
		TextBox textBox_6 = new TextBox();
		panelRegistro.add(textBox_6, 264, 414);
		textBox_6.setSize("213px", "17px");
		
		TextBox textBox_7 = new TextBox();
		panelRegistro.add(textBox_7, 264, 371);
		textBox_7.setSize("213px", "17px");
		
		ListBox listBox_1 = new ListBox();
		panelRegistro.add(listBox_1, 264, 507);
		listBox_1.setSize("128px", "27px");
		
		ListBox listBox_2 = new ListBox();
		panelRegistro.add(listBox_2, 400, 507);
		listBox_2.setSize("87px", "27px");
		
		Button btnNewButton = new Button("New button");
		btnNewButton.setText("Finalizar");
		panelRegistro.add(btnNewButton, 353, 595);
		btnNewButton.setSize("91px", "29px");
		
		Button btnNewButton_1 = new Button("New button");
		btnNewButton_1.setText("Cancelar");
		panelRegistro.add(btnNewButton_1, 450, 595);
		btnNewButton_1.setSize("91px", "29px");
		
//		Label lblNewLabel = new Label("New label");
//		panelRegistro.setWidget(lblNewLabel);
//		lblNewLabel.setSize("100%", "100%");

		Button btnCorrigeFacil = new Button("Corrige facil");
		btnCorrigeFacil.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
			}
		});
		btnCorrigeFacil.setStyleName("gwt-TituloGrande-P-para_Button");
		btnCorrigeFacil.setText("Corrige Fácil");
		menuPanel.add(btnCorrigeFacil, 1, 21);
		btnCorrigeFacil.setSize("231px", "61px");

		AbsolutePanel absolutePanel_8 = new AbsolutePanel();
		absolutePanel_8.setStyleName("gwt-Separador");
		rootPanel.add(absolutePanel_8, 238, 45);
		absolutePanel_8.setSize("912px", "3px");

		Button btnSair = new Button("Sair");
		btnSair.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
			}
		});
		btnSair.setStyleName("gwt-Button_invisivel_com_Borda");
		rootPanel.add(btnSair, 1048, 10);
		btnSair.setSize("102px", "29px");

		Label lblBemVindo = new Label("Bem vindo, João");
		lblBemVindo.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
		rootPanel.add(lblBemVindo, 238, 16);

		DateLabel dateLabel = new DateLabel();
		dateLabel.addAttachHandler(new Handler() {
			public void onAttachOrDetach(AttachEvent event) {
			}
		});
		dateLabel.setWordWrap(false);
		rootPanel.add(dateLabel, 970, 16);
		rootPanel.setVisible(true);

	}

	public AbsolutePanel getPanel() {
		return rootPanel;
	}
}